/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boogie.designpatterns.state;

import java.util.HashMap;
import java.util.Map;

/**
 * Asta ii automatu cu stari finite
 * @author boogie
 */
public class StateMachineThingy {
    private final Map<String,State> states;
    /*
     * mai mere si asa
     * astea nu au modificator de visibilitate (google what that means ppl)
     * 
     * final State firstState = new FirstState(this);
     * final State secondState = new SecondState(this);
     * final State thridState = new ThirdState(this);
     * 
     * void enterState(State state){
     *      this.currentState = state;
     * {
     * 
     * dar varianta asta nu ii foarte buna pt foarte multe stari(
     * gen cum ii pt automatu cu stari smechere de la LFTC care are cam
     * 10000000 de stari :P
     * )
     */

    private State currentState;
    
    public StateMachineThingy() {
        states = new HashMap<>();
        //adding the states
        states.put("first", new FirstState(this));
        states.put("second", new SecondState(this));
        states.put("third", new ThirdState(this));
        
        currentState = states.get("first");
        //intram in prima state (by default as they say)
    }
    
    
    public void enterState(String stateName){
        currentState = states.get(stateName);
    }
    
    public void doStateThingies(){
        currentState.handleState();//se cheama polimorfism. google it
    }
    
    
    
}
